<template>
  <div class="login-container">
    <van-nav-bar title="登录">
      <template #left>
        <img class="logo" src="@/assets/images/logo.png" />
      </template>
    </van-nav-bar>

    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        label="手机号"
        placeholder="手机号"
        required
        :rules="[
          { required: true, message: '请填写手机号', trigger: 'onChange' },
          { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号',trigger: 'onChange' },
        ]"
      />
      <van-field
        v-model="password"
        type="number"
        label="验证码"
        placeholder="验证码"
        required
        :rules="[
        { required: true, message: '请填写验证码',trigger: 'onChange' },
        {pattern:/^\d{6}$/,message:'请输入正确的验证码',trigger: 'onChange'}
        ]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data () {
    return {
      username: '13851604242',
      password: '014045'
    }
  },
  methods: {
    onSubmit (values) {
      console.log('submit', values)
    }
  }
}
</script>

<style lang="less" scoped>
.logo {
  width: 100px;
  height: 30px;
}
// .van-nav-bar {
//   background: #007bff;
// }

// /* /deep/ 就是把data-v-hash值选择器写到类名的前面 */
// /deep/ .van-nav-bar__title {
//   color: white;
// }
</style>
